Kafka handle position and commit offset on seek operations#3453
Kafka handle position and commit offset on seek operations#3453ozangunalp wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3453 +/- ##
============================================
+ Coverage 77.47% 77.87% +0.40%
- Complexity 3778 5619 +1841
============================================
Files 306 486 +180
Lines 12673 18774 +6101
Branches 1648 2312 +664
============================================
+ Hits 9818 14620 +4802
- Misses 2116 3017 +901
- Partials 739 1137 +398
🚀 New features to boost your workflow:
|
2635bae to
73b713b
Compare
73b713b to
3c58ca8
Compare
3c58ca8 to
63dfc6b
Compare
When seek(), seekToBeginning(), or seekToEnd() is called on the consumer, reset the commit handler's per-partition offset tracking.
…rror (ex. WakeupException)
63dfc6b to
249df9b
Compare
cescoffier
left a comment
There was a problem hiding this comment.
Should KafkaCheckpointCommit also implement partitionsSeeked?
|
|
||
| @Override | ||
| public void partitionsSeeked(Collection<TopicPartition> partitions) { | ||
| delegate.partitionsSeeked(partitions); |
There was a problem hiding this comment.
After a seek, the ordered groups for the affected partitions are holding a stale state (pending counts, buffered items). This could cause records from the new position to be incorrectly ordered or dropped if the group's pending counter is non-zero.
I think we should consider whether the ordered groups for sought partitions should be canceled and removed, similar to what partitionsRevoked does.
| public class KafkaThrottledLatestProcessedCommit extends ContextHolder implements KafkaCommitHandler { | ||
|
|
||
| private final Map<TopicPartition, OffsetStore> offsetStores = new HashMap<>(); | ||
| private final Set<TopicPartition> seekedPartitions = new HashSet<>(); |
There was a problem hiding this comment.
Use a copy on write variant - HashSet is not thread-safe.
There was a problem hiding this comment.
Like the offset stores, it is only accessed on the channel context
onPartitionsSeekedcallback toKafkaConsumerRebalanceListenerandpartitionsSeekedto KafkaCommitHandler interface. On seek operations, the Kafka consumer clears the poller buffer and callspartitionsSeekedon commit handlers.